#pragma once

#include <list>
#include <map>
#include <set>
#include "..\common\common.h"
//#include "mission_event.h"

class mission;
class mission_event;

typedef std::list<mission*> mission_list;
typedef std::list<AI9::GeneralType> gtype_list;

class mission
{
public:
	mission(mission *parent_mission, const gtype_list &troop) : m_parent(parent_mission), m_troop(troop) {}

	virtual void execute() = 0;
	virtual void event_arrived(mission_event *e) = 0;
	virtual void cancel() = 0;
	virtual std::string get_type() = 0;

	virtual void upcall_event(mission_event *);

	const mission_list& get_subtask_list() const;
	void add_subtask(mission *m) { m_subtasks.insert(m); }
	void remove_subtask(mission *m) { m_subtasks.erase(m); }

	void free_general(AI9::GeneralType);

	void set_army_state(AI9::GeneralType general, bool state) { army_state[general] = state; }
	gtype_list get_free_troop();

public:
	mission* m_parent;
	gtype_list m_troop;
	map<AI9::GeneralType, bool> army_state;	//	general -> is_busy?
	typedef set<mission*> mission_set;
	mission_set m_subtasks;
};


